package com.khh.action;

import org.apache.struts2.ServletActionContext;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by webrx on 2017-09-13.
 */
public class Demo {

    public void aa(){
        System.out.println("haohai");
    }

    public void execute() throws IOException {
        //直接在网页输出信息
        HttpServletResponse res = ServletActionContext.getResponse();
        res.setCharacterEncoding("utf-8");
        res.setContentType("text/html;charset=utf-8");
        PrintWriter out = res.getWriter();
        out.print("<h1>Struts2.5.10 入门案例</h1>");
        out.flush();
        out.close();

        //控制台输出信息
        System.out.println("Hello Struts 2.5.10");
    }



}
